package com.hxzy.feign.fallbackfactory;

import com.hxzy.common.enums.AckCode;
import com.hxzy.common.resp.R;
import com.hxzy.feign.OrderServiceFeign;
import com.hxzy.order.req.OrderReq;
import com.hxzy.order.req.OrderSearchReq;
import com.hxzy.order.resp.OrderResp;
import lombok.extern.log4j.Log4j2;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author wy
 * @Description  订单服务的feign定义
 * @Date 2023/10/12 16:15
 * @Version 1.0
 */
@Component
@Log4j2
public class OrderServiceFeignFallbackFactory implements FallbackFactory<OrderServiceFeign> {


    @Override
    public OrderServiceFeign create(Throwable cause) {
        //记录错误日志
        log.error(cause);
        return new OrderServiceFeignFall();
    }

    class OrderServiceFeignFall implements OrderServiceFeign{

        @Override
        public R<OrderResp> orderFindById(Integer id) {
            return R.build(AckCode.FAIL);
        }

        @Override
        public R<Map<String, Object>> orderData(OrderSearchReq req) {
            return null;
        }

        @Override
        public R<Map<String, Object>> orderDataParam(Integer page, Integer size, Integer userId, String name) {
            return null;
        }

        @Override
        public R<String> createOrder(OrderReq req) {
            return null;
        }
    }

}
